package com.biglead.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.biglead.demo.mapper.SecKillGoodsMapper;
import com.biglead.demo.pojo.SeckillGoods;
import com.biglead.demo.service.SecKillGoodsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class SecKillGoodsServiceImpl implements SecKillGoodsService {

    @Resource
    private SecKillGoodsMapper secKillGoodsMapper;

    @Override
    public SeckillGoods findByGoodsId(Long goodsId) {
        return secKillGoodsMapper.selectOne(new QueryWrapper<SeckillGoods>().eq("goods_id", goodsId));
    }

    @Override
    public int updateById(SeckillGoods seckillGoods) {
        return secKillGoodsMapper.updateById(seckillGoods);
    }

    @Override
    public int updateStockCount(SeckillGoods seckillGoods) {
        return secKillGoodsMapper.updateStockCount(seckillGoods);
    }

    @Override
    public List<SeckillGoods> findAllSecKillGoods() {
     return secKillGoodsMapper.selectList(new QueryWrapper<SeckillGoods>());
    }

}
